package com.xjzd.aop;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.aopalliance.aop.Advice;
import org.springframework.aop.Pointcut;
import org.springframework.aop.support.AbstractPointcutAdvisor;
import org.springframework.aop.support.ComposablePointcut;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;

@Getter
@EqualsAndHashCode(callSuper = true)
public class InterLayerInfoAnnotationAdvisor extends AbstractPointcutAdvisor {

    private final Advice advice;

    private final Pointcut pointcut;

    public InterLayerInfoAnnotationAdvisor() {
        this.advice = new InterLayerInfoAnnotationInterceptor();
        Pointcut classPointcut = new AnnotationMatchingPointcut(InterLayerInfo.class, true);
        Pointcut methodPointcut = new AnnotationMatchingPointcut(null, InterLayerInfo.class, true);
        this.pointcut = new ComposablePointcut(classPointcut).union(methodPointcut);
    }

}
